package fr.esisar.cs420.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;

import fr.esisar.cs420.traitement.Album;

public class GestionCommandes extends Shell {

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String args[]) {
		
	}

	/**
	 * Create the shell.
	 * @param display
	 */
	public GestionCommandes(Display display) {
		super(display, SWT.SHELL_TRIM);
		
		Group grpGrerVosCommandes = new Group(this, SWT.NONE);
		grpGrerVosCommandes.setText("Saisissez une  commande");
		grpGrerVosCommandes.setBounds(10, 10, 294, 142);
		
		Button btnNewButton = new Button(grpGrerVosCommandes, SWT.NONE);
		btnNewButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				try {
					Display display = Display.getDefault();
					GestionCommande shell = new GestionCommande(display);
					shell.open();
					shell.layout();
					while (!shell.isDisposed()) {
						if (!display.readAndDispatch()) {
							display.sleep();
						}
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
				Album.removeAlbum();	
			}
		});
		btnNewButton.setBounds(41, 57, 201, 25);
		btnNewButton.setText("Saisir une commande");
		
		Group grpAfficherVosCommandes = new Group(this, SWT.NONE);
		grpAfficherVosCommandes.setText("Afficher vos commandes");
		grpAfficherVosCommandes.setBounds(347, 10, 268, 142);
		
		Button btnAfficherVosCommandes = new Button(grpAfficherVosCommandes, SWT.NONE);
		btnAfficherVosCommandes.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				try {
					Display display = Display.getDefault();
					AfficherCommandes shell = new AfficherCommandes(display);
					shell.open();
					shell.layout();
					while (!shell.isDisposed()) {
						if (!display.readAndDispatch()) {
							display.sleep();
						}
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
		btnAfficherVosCommandes.setText("Afficher vos commandes");
		btnAfficherVosCommandes.setBounds(41, 57, 201, 25);
		createContents();
	}

	/**
	 * Create contents of the shell.
	 */
	protected void createContents() {
		setText("Gestion des commande");
		setSize(651, 224);

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
